//
//  NewsViewController.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/3/17.
//  Copyright © 2017年 蓝布鲁. All rights reserved.
//

#import "NewsViewController.h"
#import "NewsView.h"
#import "MySlideBar.h"


@interface NewsViewController ()

// UI
@property (nonatomic, retain)MySlideBar *slideBar;
@property (nonatomic,retain)NSMutableArray *newsArray;

@end

@implementation NewsViewController

#pragma mark - 初始化方法
-(instancetype)init{
    if (self==[super init]) {
        // 设置标题&TabBar图标
        self.title = @"资讯";
        self.tabBarItem.image = [UIImage imageNamed:@"news_tabBar"];
        self.hidesBottomBarWhenPushed = false;
        
        self.automaticallyAdjustsScrollViewInsets = false;
    }
    return self;
}

#pragma mark - 系统回调方法
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupSliderBar];
    
    [self setupNewsView];
}

#pragma mark - 自定义方法
-(void)setupSliderBar {
    // 设置顶部sliderBar
#pragma mark 特殊处理，等到布局框架更新，需要修改
    if (IS_IPHONEX) {
        self.slideBar = [[MySlideBar alloc] initWithFrame:CGRectMake(0, 88, SCREEN_WIDTH, SCREEN_HEIGHT-88 - 49)];
    }else{
        self.slideBar = [[MySlideBar alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64 - 49)];
    }
    
    
    self.slideBar.itemColor = [UIColor blackColor];
    self.slideBar.itemSelectedColor = [UIColor orangeColor];
    self.slideBar.sliderColor = [UIColor orangeColor];
    self.slideBar.itemScrollView.backgroundColor = [UIColor lightGrayColor];
    
    [self.view addSubview:self.slideBar];
    
}

-(void)setupNewsView {
    self.newsArray = [[NSMutableArray alloc] init];
    
    // 公告
    NewsView *noticeView = [[NewsView alloc] initWithType:NoticeType];
    [self.newsArray addObject:noticeView];
    
    // 活动
    NewsView *activityView = [[NewsView alloc] initWithType:ActivityType];
    [self.newsArray addObject:activityView];
    
    // 刷新sliderBar
    [self.slideBar setItemsTitle:@[@"公告", @"活动"] pageViews:self.newsArray autoMargin:true];
}








@end
